package com.project.housesalesystem.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.housesalesystem.bean.House;
import com.project.housesalesystem.bean.Users;
import com.project.housesalesystem.mapper.HouseMapper;
import com.project.housesalesystem.mapper.UsersMapper;
import com.project.housesalesystem.service.HouseService;
import com.project.housesalesystem.service.UsersService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
@Slf4j
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {

    /**
     * 查询所有
     */
    public List<Users> selectAll(Users user) {
        return baseMapper.selectAll(user);
    }

    @Override
    public IPage<Users> getUsersPage(Map<String, Object> params) {

        Page<Users> page = new Page<>(Long.parseLong(params.get("pageNum")+""), Long.parseLong(""+params.get("pageSize")));

        // 查询数据
        Page<Users> usersPage = this.baseMapper.selectUsersPage(page, params.get("keywords")+"");

        // 实体转换
        return usersPage;

    }

}
